package com.normal.main.fragment

import android.os.Bundle
import android.view.View
import androidx.core.net.toUri
import androidx.core.os.bundleOf
import androidx.navigation.NavDeepLinkRequest
import androidx.navigation.NavOptions
import androidx.navigation.Navigator
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import com.normal.main.R
import com.normal.main.databinding.FragmentHomeBinding
import com.normal.zbase.impl.base.BaseFragment
import com.normal.zbase.impl.tools.extend.click
import com.normal.zbase.impl.tools.extend.viewBinding


/**
 * Created by zsf on 2021/1/4 13:59
 * ******************************************
 * *
 * ******************************************
 */
class HomeFragment : BaseFragment<FragmentHomeBinding>() {
    override fun viewBinding(): FragmentHomeBinding {
        return FragmentHomeBinding.inflate(layoutInflater)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    override fun initView(view: View, savedInstanceState: Bundle?) {
        super.initView(view, savedInstanceState)
        viewBinding.btnClick.setOnClickListener {
//            navigate(R.id.secondFragment)
            findNavController().navigate(
                R.id.action_homeFragment_to_mainFragment
            )
        }
        viewBinding.btnBackLast.setOnClickListener {
            //返回到上一个
            findNavController().navigateUp()

        }
        viewBinding.btnBack.setOnClickListener {
            //返回到第一个界面，并清空
            findNavController().popBackStack(R.id.loginFragment, false)
        }


        viewBinding.btnBackLastClear.setOnClickListener {
            findNavController().backQueue.clear()
            findNavController().navigate(R.id.loginFragment)

        }
        viewBinding.btnActivity.setOnClickListener {
//            val request = NavDeepLinkRequest.Builder
//                .fromUri("myframe://com.cp.thridFragment/mine/1".toUri())
//                .build()
//            NavOptions.Builder().build().
            findNavController().navigate("myframe://com.cp.thridFragment/mine/1/2".toUri())
        }


    }
}